
package com.weiqiao.api.repository.impl;


import com.weiqiao.api.repository.IReceiptApiRepository;
import com.weiqiao.base.dao.impl.BaseMongoDaoImpl;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("ReceiptApiRepositoryImpl")
public class ReceiptApiRepositoryImpl extends BaseMongoDaoImpl implements IReceiptApiRepository {
    private String collectionName = "app_user_receipt_";

    @Override
    public boolean addReceipt(int company_id, String json) {
        return this.inSert(collectionName + company_id, json);
    }

    @Override
    public List<String> findReceipt(int company_id, Bson filter, Bson filterSort, int skip, int limit) {
        List<String> list = this.findFilterSortSkipLimit(collectionName + company_id, filter, filterSort, skip, limit);
        return list;
    }

    @Override
    public String queryOneReceiptById(int company_id, Bson filter) {
        return this.findOne(collectionName + company_id, filter);
    }

    @Override
    public List<String> queryOneReceiptByIds(int company_id, Bson filter) {
        return this.findFilter(collectionName + company_id, filter);
    }

    @Override
    public boolean updateOneRecepit(int company_id, Bson filter, Document doc) {
        return this.updateOne(collectionName + company_id, filter, doc, false);
    }

    @Override
    public boolean updateRecepits(int company_id, Bson filter, Document doc) {
        return this.updateMany(collectionName + company_id, filter, doc, false);
    }

    @Override
    public int countNum(int company_id, Bson filter) {
        return this.statististics(collectionName + company_id, filter);
    }
}
